<style lang="less">
    // .main .content-wrapper {
    //   padding: 0;
    //   height: calc(100% - 80px);
    //   overflow: auto;
    // }
    .card_style {
        height: 100%;
        width: 100%;
        overflow: hidden;
        .ivu-card-body {
            padding: 0px;
        }
    }
    .page_style {
        margin-bottom: 20px;
        margin-top: 10px;
        text-align: right;
    }
    .bench_search {
        margin-bottom: 10px;
    }
    .nopadding .ivu-table-cell {
        padding: 0px 0px;
    }
    .title{
        text-align: center;
        font-size: 1.5rem;
        padding: 20px;
    }
    .notice-name {
        line-height: 2.5;
        margin-top: 6%;
    }
    .notice-context {
        text-indent: 2em;
        line-height: 2.5;
    }
    .notice-content1 {
        padding: 0 4% 0 12%;
        position:relative;
    }
    .notice-address {
        text-align: right;
        margin-top: 10%;
    }
    .notice-date {
        text-align: right;
    }
    .text-line {
        border-color: #878787;
        border-style: solid;
        border-top-width: 0px;
        border-right-width: 0px;
        border-bottom-width: 1px;
        border-left-width: 0px;
        text-align: center;
    }
    .text-line-date {
        border-color: #878787;
        border-style: solid;
        border-top-width: 0px;
        border-right-width: 0px;
        border-bottom-width: 1px;
        border-left-width: 0px;
        width: 10%;
        text-align: center;
    }
    .text-line-address {
        border-color: #878787;
        border-style: solid;
        border-top-width: 0px;
        border-right-width: 0px;
        border-bottom-width: 1px;
        border-left-width: 0px;
        width: 15%;
        text-align: center;
    }
    .print-btn {
        padding: 15px;
        float: right;
    }
    .code-img2 {
        height: 120px;
        width: 120px;
        top: 70%;
        left: 4%;
        position: absolute;
    }
    .code-img1 {
        height: 60%;
        width: 90%;
        margin-left: 5%;
    }
</style>
<template>
    <Card class="card_style" :bordered="false" :dis-hover="true">
        <Tabs :animated="false" @on-click="searchData(tab_index)" v-model="tab_index">
            <TabPane :label="'全部('+tab_info[0][0]+')'">
                <Row class="bench_search">
                    <Col span="5" offset="1">
                        <span>申请人：</span>
                        <Input style="width: 70%;" v-model="applyname" />
                    </Col>
                    <Col span="6">
                        <span>业务编号：</span>
                        <Input style="width: 70%;" v-model="order_code" />
                    </Col>
                    <Col span="7">
                        <span>申请时间：</span>
                        <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                                    placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                    </Col>
                    <Button type="info" @click="searchData(tab_index)" style="margin-right: 5px"><Icon type="ios-clock-outline" /> 刷新</Button>
                    <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
                </Row>
                <Table border :columns="columns1" :data="datalist"></Table>
                <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class="page_style"/>
            </TabPane>
            <TabPane :label="'待提报('+tab_info[0][1]+')'">
                <Row class="bench_search">
                    <Col span="5" offset="1">
                        <span>申请人：</span>
                        <Input style="width: 70%;" v-model="applyname" />
                    </Col>
                    <Col span="6">
                        <span>业务编号：</span>
                        <Input style="width: 70%;" v-model="order_code" />
                    </Col>
                    <Col span="7">
                        <span>申请时间：</span>
                        <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                                    placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                    </Col>
                    <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
                </Row>
                <Table border :columns="columns1" :data="datalist" on-expand="expandData()"></Table>
                <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class="page_style"/>
            </TabPane>
            <TabPane :label="'待受理('+tab_info[0][2]+')'">
                <Row class="bench_search">
                    <Col span="5" offset="1">
                        <span>申请人：</span>
                        <Input style="width: 70%;" v-model="applyname" />
                    </Col>
                    <Col span="6">
                        <span>业务编号：</span>
                        <Input style="width: 70%;" v-model="order_code" />
                    </Col>
                    <Col span="7">
                        <span>申请时间：</span>
                        <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                                    placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                    </Col>
                    <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
                </Row>
                <Table border :columns="columns1" :data="datalist"></Table>
                <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class-name="page_style"/>
            </TabPane>
            <TabPane :label="'办理中('+tab_info[0][3]+')'">
                <Row class="bench_search">
                    <Col span="5" offset="1">
                        <span>申请人：</span>
                        <Input style="width: 70%;" v-model="applyname" />
                    </Col>
                    <Col span="6">
                        <span>业务编号：</span>
                        <Input style="width: 70%;" v-model="order_code" />
                    </Col>
                    <Col span="7">
                        <span>申请时间：</span>
                        <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                                    placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                    </Col>
                    <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
                </Row>
                <Table border :columns="columns1" :data="datalist"></Table>
                <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class="page_style"/>
            </TabPane>
            <TabPane :label="'转件中('+tab_info[0][4]+')'">
                <Row class="bench_search">
                    <Col span="5" offset="1">
                        <span>申请人：</span>
                        <Input style="width: 70%;" v-model="applyname" />
                    </Col>
                    <Col span="6">
                        <span>业务编号：</span>
                        <Input style="width: 70%;" v-model="order_code" />
                    </Col>
                    <Col span="7">
                        <span>申请时间：</span>
                        <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                                    placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                    </Col>
                    <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
                </Row>
                <Table border :columns="columns1" :data="datalist"></Table>
                <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class="page_style"/>
            </TabPane>
            <TabPane :label="'待办结('+tab_info[0][5]+')'">
                <Row class="bench_search">
                    <Col span="5" offset="1">
                        <span>申请人：</span>
                        <Input style="width: 70%;" v-model="applyname" />
                    </Col>
                    <Col span="6">
                        <span>业务编号：</span>
                        <Input style="width: 70%;" v-model="order_code" />
                    </Col>
                    <Col span="7">
                        <span>申请时间：</span>
                        <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                                    placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                    </Col>
                    <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
                </Row>
                <Table border :columns="columns1" :data="datalist"></Table>
                <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class="page_style"/>
            </TabPane>
            <TabPane :label="'办结成功('+tab_info[0][6]+')'">
                <Row class="bench_search">
                    <Col span="5" offset="1">
                        <span>申请人：</span>
                        <Input style="width: 70%;" v-model="applyname" />
                    </Col>
                    <Col span="6">
                        <span>业务编号：</span>
                        <Input style="width: 70%;" v-model="order_code" />
                    </Col>
                    <Col span="7">
                        <span>申请时间：</span>
                        <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                                    placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                    </Col>
                    <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
                </Row>
                <Table border :columns="columns1" :data="datalist"></Table>
                <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class="page_style"/>
            </TabPane>
            <TabPane :label="'办结失败('+tab_info[0][7]+')'">
                <Row class="bench_search">
                    <Col span="5" offset="1">
                        <span>申请人：</span>
                        <Input style="width: 70%;" v-model="applyname" />
                    </Col>
                    <Col span="6">
                        <span>业务编号：</span>
                        <Input style="width: 70%;" v-model="order_code" />
                    </Col>
                    <Col span="7">
                        <span>申请时间：</span>
                        <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                                    placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                    </Col>
                    <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
                </Row>
                <Table border :columns="columns1" :data="datalist"></Table>
                <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class="page_style"/>
            </TabPane>
            <!-- <TabPane label="历史">
              <Row class="bench_search">
                <Col span="5" offset="1">
                  <span>申请人：</span>
                  <Input style="width: 70%;" v-model="applyname" />
                </Col>
                <Col span="6">
                  <span>业务编号：</span>
                  <Input style="width: 70%;" v-model="order_code" />
                </Col>
                <Col span="7">
                  <span>申请时间：</span>
                  <DatePicker type="datetimerange" format="yyyy/MM/dd" transfer=""
                  placement="bottom-end" style="width: 200px" v-model="applytime"></DatePicker>
                </Col>
                <Button type="info" @click="searchData(tab_index)"><Icon type="ios-search" /> 搜索</Button>
              </Row>
              <Table border :columns="columns1" :data="datalist"></Table>
              <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="change" class="page_style"/>
            </TabPane> -->
        </Tabs>
        <!-- 全部模态框功能统一显示 -->
        <Modal v-model="modelShow.show" :title="modelShow.title" width="900">
            <!-- 订单进度模态框 -->
            <template v-if="processModal.show">
                <Steps :current="processModal.step_num" direction="vertical" style="margin-left: 100px;width: 70%;">
                    <Step v-for="(item, index) in processModal.process_list" v-bind:key="index"
                          :title="item.step_title" :content="item.text"></Step>
                </Steps>
            </template>
            <!-- 订单处理功能模态框 -->
            <template v-if="modalInfo.show">
                <Form label-position="right" :label-width="100">
                    <Row>
                        <Col span="5" class="ivu-form-item-label">{{modalInfo.params_name}}：</Col>
                        <Col span="16" class="ivu-form-item-content">
                            <Input v-if="modalInfo.params_type == 'textarea'" v-model="modalInfo.text"
                                   type="textarea" :autosize="{minRows: 3,maxRows: 7}" :disabled="modalInfo.update_flag"></Input>
                            <Select v-if="modalInfo.params_type == 'select'" v-model="modalInfo.text" filterable>
                                <Option v-for="company in company_list" :value="company.code"
                                        v-bind:key="company.key">{{company.sq_name }} {{company.name}}（{{company.code}}）</Option>
                            </Select>
                        </Col>
                    </Row>
                </Form>
            </template>
            <!-- 通知单模态框 -->
            <template v-if="modal">
                <div style="background-color:white;line-height: 2.5;position:relative;width: 100%;height: 500px;" class="notice-content" id="printMe1">
                    <div class="title">便民服务事项受理通知单</div>
                    <div style="font-size: 1rem">
                        <div class="notice-name">尊敬的 <u>{{printData.name}}</u> 先生/女士:</div>
                        <div class="notice-context">您于 <u>{{printData.aa}}</u>年 <u>{{printData.bb}}</u>月
                            <u>{{printData.cc}}</u>日来我社区提报的 <u>{{printData.title}}</u> 事项,我社区已经受理,状态为
                            <u><span v-if="printData.state == '2'">办理完结</span></u> (办理完结;流转至其他社区;提报至业务部门)。
                        </div>
                        <div class="notice-address">沈阳市 <u>{{address}}</u> 社区居民委员会</div>
                        <div class="notice-date">
                            <u>{{printData.aa}}</u>年
                            <u>{{printData.bb}}</u>月
                            <u>{{printData.cc}}</u>日
                        </div>
                    </div>
                    <div id="qrcode1" ref="qrcode1" style="position: absolute;margin-top: -12%;"></div>
                </div>
            </template>
            <!-- 要件模态框 -->
            <template v-if="modal1">
                <div style="background-color:white;line-height: 2.5;" class="" id="printMe1">
                    <div style="height:auto">
                        <img :src="paramsImg" alt="" class="code-img1" width="100%">
                    </div>
                </div>
            </template>
            <!-- 电子证照图片 -->
            <template v-if="resultImg.show">
                <div class="" id="printMe1">
                    <img :src="resultImg.imgs" style="width: 100%"/>
                </div>
            </template>
            <!-- 空表模态框 -->
            <template v-if="modal2">
                <Row>
                    <Col span="24" id="printMe1" class="ivu-form-item-content" style="text-align: center">
                        <embed width="800" height="600" :src="paramskImg"></embed>
                    </Col>
                </Row>
            </template>
            <div slot="footer">
                <Button type="success" size="large" @click="acceptBtn" v-if="modalInfo.show&&!modalInfo.update_flag">确定</Button>
                <Button type="success" size="large" v-print="'#printMe1'" v-if="modal || modal1 || resultImg.show">打印</Button>
                <Button type="error" @click="modelShow.show=false">关闭</Button>
            </div>
        </Modal>
    </Card>
</template>
<script>
import { eventorderlist, setorderapply, tabcount, date2str, orderProcess,
  getUserByMZList, getPDFByOrderCode, deleteOrder } from '@/api/eventlist'
import ercode from '@/assets/images/ercode.jpeg'
import expandRow from './components/table-other/index'
// import QRCode from 'qrcodejs2'
export default {
  components: {
    // expandRow
  },
  data () {
    return {
      today: new Date().getTime(),
      paramsImg: '',
      paramskImg: '',
      paramsArr: [],
      codeUrl: 'http://sjb.tripln.com/views/manage/iview_order_detail.html?code=SQ1561461755825',
      printData: {
        aa: '',
        bb: '',
        cc: ''
      },
      modelShow: { show: false, title: '' },
      modal: false,
      modal1: false,
      modal2: false,
      tab_index: 0,
      // 每个标签页的名称和对应订单数量，标签与状态转换字典
      tab_info: [
        [ 0, 0, 0, 0, 0, 0, 0, 0 ],
        [ null, '9', '0', '1', '8', '7', '2', '3' ],
        { a0: 2, a1: 3, a2: 6, a3: 7, a7: 5, a8: 4, a81: 4, a82: 4, a9: 1 }
      ],
      resultImg: { show: false, imgs: [] },
      processModal: { show: false, process_list: [] },
      currentPageNo: 1,
      currentPageSize: 10,
      applyname: '',
      order_code: '',
      applytime: [],
      totalnum: 0,
      columns1: [
        { title: '',
          type: 'expand',
          width: 40,
          align: 'center',
          render: (h, params) => {
            return h(expandRow,
              {
                props: { params: params },
                on: {
                  breachRun: (type, data) => {
                    if (type === 1) {
                      this.viewProcess(data)
                      this.modal = false
                      this.modalInfo.show = false
                      this.modal1 = false
                      this.modal2 = false
                      this.resultImg.show = false
                    } else if (type === 2) {
                      console.log(data.code, '!!!!')
                      // 调用一个方法弹出带二维码的模态框
                      var url = 'http://sjb.tripln.com/views/manage/iview_order_detail.html?code=' + data.code
                      this.modal = true
                      this.modalInfo.show = false
                      this.modal1 = false
                      this.processModal.show = false
                      this.modal2 = false
                      this.resultImg.show = false
                      this.printData = data
                      this.printData.create_time = this.printData.create_time.substring(0, 10)
                      this.printData.aa = this.printData.create_time.substring(0, 4)
                      this.printData.bb = this.printData.create_time.substring(5, 7)
                      this.printData.cc = this.printData.create_time.substring(8, 10)
                      this.showModel(true, '便民服务事项受理通知单', url)
                    } else if (type === 3) {
                      this.popModal(data.data, data.key1, data.key2)
                      this.modal = false
                      this.modal1 = false
                      this.processModal.show = false
                      this.modal2 = false
                    } else if (type === 4) {
                      this.handlerItem(data.data, data.key1, data.key2)
                      this.modal = false
                      this.modal1 = false
                      this.processModal.show = false
                      this.modalInfo.show = false
                      this.modal2 = false
                    } else if (type === 5) {
                      this.processModal.show = false
                      this.modal = false
                      this.modal2 = false
                      this.modalInfo.show = false
                      this.resultImg.show = false
                      this.modal1 = true
                      this.paramsImg = data
                      this.showModel(true, '要件预览打印', url)
                    } else if (type === 6) {
                      this.paramskImg = ''
                      if (data.item_id === '11210101000000MZJD5212000207000') {
                        getPDFByOrderCode({ code: data.code }).then(res => {
                          if (res.data.errcode === 0) {
                            this.paramskImg = 'data:application/pdf;base64,' + res.data.data
                            this.modal = false
                            this.modalInfo.show = false
                            this.modal1 = false
                            this.processModal.show = false
                            this.resultImg.show = false
                            this.modal2 = true
                            this.showModel(true, '打印表格')
                            this.refreshData()
                          } else {
                            this.$Notice.error({ title: '失败', desc: res.data.errmsg })
                          }
                        })
                      } else {
                        this.paramskImg = params.row.form_url
                        this.modal = false
                        this.modalInfo.show = false
                        this.modal1 = false
                        this.processModal.show = false
                        this.resultImg.show = false
                        this.modal2 = true
                        this.showModel(true, '打印表格')
                        this.refreshData()
                      }
                    }
                  }
                }
              })
          }
        },
        {
          title: '事项名称',
          key: 'title',
          minWidth: 190,
          render: (h, params) => {
            let temp = []
            // 办理中和待办结的订单有时效标识
            if (params.row.state === '1' || params.row.state === '7') {
              let create_time1 = new Date(params.row.create_time).getTime()
              create_time1 += 86400000 * params.row.PROMISE_DAY
              if (create_time1 < this.today) {
                temp.push(h('Icon', { props: { type: 'md-alarm' }, style: { color: '#f00' } }))
              } else if ((create_time1 - 86400000 * 3) < this.today) {
                temp.push(h('Icon', { props: { type: 'md-alarm' }, style: { color: '#f90' } }))
              }
            }
            temp.push(h('span', params.row.title))
            return h('div', temp)
          }
        },
        { title: '业务编号', key: 'code', width: 150 },
        { title: '申请人', key: 'name', width: 80 },
        { title: '手机号', key: 'mobile1', width: 115 },
        { title: '身份证', key: 'cardnoFilter', width: 160 },
        { title: '状态', key: 'process_name', width: 85, align: 'center', className: 'nopadding' },
        { title: '申请时间', key: 'create_time', width: 140, align: 'center', className: 'nopadding' },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          className: 'nopadding',
          minWidth: 130,
          render: (h, params) => {
            let temp = []
            let action1 = JSON.parse(params.row.action)
            for (let key in action1) {
              if (action1[key].type === 'button' && action1[key].next_process_id !== '-1') {
                temp.push(
                  h('Button', {
                    props: { type: 'success', size: 'small' },
                    style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                    on: {
                      click: () => {
                        // 操作类型非下划线开头时，表示功能按钮
                        if (action1[key].params_type && action1[key].params_type.indexOf('_') !== 0) {
                          this.modal = false
                          this.modal1 = false
                          this.processModal.show = false
                          this.modal2 = false
                          this.resultImg.show = false
                          this.popModal(params.row, action1[key], key)
                        } else {
                          this.modal = false
                          this.modal1 = false
                          this.processModal.show = false
                          this.modal2 = false
                          this.resultImg.show = false
                          this.handlerItem(params.row, key, action1[key])
                        }
                      }
                    }
                  }, action1[key].name)
                )
              }
            }
            // 除了草稿状态，其他都默认加上查看按钮
            if (params.row.state === '9') {
              temp.push(
                h('Button', {
                  props: { type: 'info', size: 'small' },
                  style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                  on: {
                    click: () => {
                      this.updateInfo(params.row, '1')
                    }
                  }
                }, '编辑')
              )
              if (params.row.order_del_flag === '0') {
                temp.push(
                  h('Button', {
                    props: { type: 'error', size: 'small' },
                    style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                    on: {
                      click: () => {
                        this.deleteInfo(params.row)
                      }
                    }
                  }, '撤销')
                )
              }
            } else {
              temp.push(
                h('Button', {
                  props: { type: 'info', size: 'small' },
                  style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                  on: {
                    click: () => {
                      this.updateInfo(params.row, '2')
                    }
                  }
                }, '查看')
              )
            }
            return h('div', temp)
          }
        }
      ],
      datalist: [],
      modalInfo: {},
      company_list: [],
      ercode
    }
  },
  computed: {
    address () {
      return this.$store.state.user.severUserInfo.data.company_name
    }
  },
  methods: {
    // 查询订单列表接口
    init (param) {
      console.log(param, 'hehehhe')
      param.pageNo = this.currentPageNo
      param.pageSize = this.currentPageSize
      param.state = param.state === '8' ? '8,81,82' : param.state
      param.disabled_id = '11210101000000MZJD5212000207000' || '11210101000000MZJD5212000216000'
      eventorderlist(param).then(res => {
        if (res.data.data) {
          this.datalist = res.data.data.results
          this.totalnum = res.data.data.totalRecord
          this.datalist.forEach(function (temp1, index) {
            temp1._expanded = false
            let tempCardno = temp1.cardno
            if (tempCardno) {
              temp1.cardnoFilter = `${tempCardno.substring(0, 10)}******${tempCardno.substring(tempCardno.length - 2)}`
            }
            let tempMobile = temp1.mobile
            if (tempMobile) {
              if (tempMobile.length === 11) {
                temp1.mobile1 = `${tempMobile.substring(0, 3)}****${tempMobile.substring(tempMobile.length - 4)}`
              } else {
                temp1.mobile1 = `${tempMobile.substring(0, 3)}****`
              }
            }
            let tempBirthday = temp1.birthday
            if (tempBirthday) {
              this.datalist[i].birthday = `${tempBirthday.substring(0, 4)}****`
            }
          })
        } else {
          this.$Notice.error({ title: '获取事项列表失败', desc: res.data.errmsg })
        }
      })
    },
    // 统计每个标签页的事项数
    initTabCount () {
      let param = {
        disabled_id: '11210101000000MZJD5212000207000'
      }
      tabcount(param).then(res => {
        if (res.data.data) {
          this.tab_info[0][0] = 0
          this.tab_info[0][1] = 0
          this.tab_info[0][2] = 0
          this.tab_info[0][3] = 0
          this.tab_info[0][4] = 0
          this.tab_info[0][5] = 0
          this.tab_info[0][6] = 0
          this.tab_info[0][7] = 0
          res.data.data.forEach(element => {
            let index = this.tab_info[2]['a' + element.state]
            if (index || index === 0) {
              this.tab_info[0][0] += element.num
              this.tab_info[0][index] += element.num
            }
          })
          this.$forceUpdate()
        }
      })
    },
    searchData (index) {
      let params = {
        name: this.applyname,
        code: this.order_code,
        disabled_id: '11210101000000MZJD5212000207000' || '11210101000000MZJD5212000216000',
        state: this.tab_info[1][index]
      }
      if (this.applytime[0]) params.start_time = date2str(this.applytime[0])
      console.log(this.applytime, 'time')
      if (this.applytime[1]) params.end_time = date2str(this.applytime[1])
      this.currentPageNo = 1
      this.init(params)
    },
    change (pageNo) {
      this.currentPageNo = pageNo
      let params = {
        name: this.applyname,
        state: this.tab_info[1][this.tab_index]
      }
      if (this.applytime[0]) params.start_time = date2str(this.applytime[0])
      if (this.applytime[1]) params.end_time = date2str(this.applytime[1])
      this.init(params)
    },
    viewProcess (item) {
      this.processModal.show = true
      this.processModal.title = item.title + '—办理进度'
      this.showModel(true, this.processModal.title)
      orderProcess({ order_code: item.code }).then(res => {
        if (res.data.data) {
          this.processModal.process_list = []
          res.data.data.forEach(element => {
            let temp = {}
            temp.step_title = element.process_name + '  ' + element.create_time
            if (element.status === '0') {
              temp.text = '未处理'
              if (element.process_id === '8') {
                temp.text += '（接收社区：' + element.accept_company_name + '）'
              }
            } else {
              if (element.handle_by === 'system') {
                temp.text = '操作人：' + element.handle_byname
              } else {
                temp.text = '操作人：' + element.accept_company_name + '-' + element.handle_byname
              }
            }
            this.processModal.process_list.push(temp)
          })
          this.processModal.step_num = this.processModal.process_list.length
          if (res.data.data[res.data.data.length - 1].state === '1') {
            this.processModal.step_num += 1
          }
        } else {
          this.$Notice.error({ title: '失败', desc: '未知原因查询失败，请重试' })
        }
      })
    },
    // 修改订单operation=1|查看订单operation=2
    updateInfo (item, operation) {
      if (item.item_id === '11210101000000MZJD5212000330000') {
        this.$router.push({
          name: 'subsistenceapplication',
          params: { cardno: item.cardno, code: item.code, operation: operation }
        })
      } else if (item.item_id.indexOf('11210101000000FCJD') === 0) {
        this.$router.push({
          name: 'house_handinformation',
          params: {
            itemid: item.item_id,
            cardno: item.cardno,
            code: item.code,
            cur_data: { tabindex: this.tab_index, pageNo: this.currentPageNo },
            operation: operation
          }
        })
      } else {
        this.$router.push({
          name: 'handinformation',
          params: {
            itemid: item.item_id,
            cardno: item.cardno,
            code: item.code,
            cur_data: { tabindex: this.tab_index, pageNo: this.currentPageNo },
            operation: operation
          }
        })
      }
    },
    // 处理事项 提报|受理|...
    handlerItem (item, key, action) {
      if (action.next_process_id === '-1') {
        if (item.img_url.indexOf('http://images.tripln.top/') === 0) {
          this.resultImg.imgs = item.img_url
        } else {
          this.resultImg.imgs = 'http://images.tripln.top/' + item.userid + '/' + item.code + '0.jpg'
        }
        console.log(this.resultImg.imgs, 'this.resultImg.imgs')
        this.resultImg.show = true
        this.showModel(true, '', '')
      } else if (action.next_process_id === '-3') {
        this.$router.push({
          name: 'handinformation',
          params: {
            itemid: item.item_id,
            cardno: item.cardno,
            code: item.code,
            cur_data: { tabindex: this.tab_index, pageNo: this.currentPageNo },
            operation: '0'
          }
        })
      } else {
        this.$Modal.confirm({
          title: '确认' + action.name + '当前事项！',
          onOk: () => {
            let aaa = { code: item.code, key: key, state: item.state }
            setorderapply(aaa).then(res => {
              if (res.data.data) {
                this.init({ 'state': this.tab_info[1][this.tab_index] })
                this.initTabCount()
              } else {
                this.$Notice.error({ title: '获取事项列表失败', desc: res.data.errmsg })
              }
            })
          }
        })
      }
    },
    deleteInfo (obj) {
      this.$Modal.confirm({
        title: '撤销后信息将无法找回，确认撤销当前事项！',
        onOk: () => {
          deleteOrder(obj.code).then(res => {
            if (res.data.data) {
              this.init({ 'state': this.tab_info[1][this.tab_index] })
              this.initTabCount()
            } else {
              this.$Notice.error({ title: '失败', desc: res.data.errmsg })
            }
          })
        }
      })
    },
    // 弹出框功能，流程中需要填写信息的按钮
    popModal (item, modal, key) {
      this.modalInfo = {
        show: true,
        process_id: item.state,
        key: key,
        code: item.code,
        title: item.title + '-' + modal.name,
        params_type: modal.params_type,
        params_code: modal.params_code,
        next_process_id: modal.next_process_id,
        params_name: modal.params_name,
        text: modal.next_process_id === '-2' ? item.reason : '',
        update_flag: modal.next_process_id === '-2'
      }
      this.showModel(true, this.modalInfo.title)
    },
    // 弹出框功能，填写信息后确定按钮
    acceptBtn () {
      let aaa = {
        code: this.modalInfo.code,
        key: this.modalInfo.key,
        state: this.modalInfo.process_id
      }
      if (this.modalInfo.params_code.indexOf('_') === 0) {
        aaa[this.modalInfo.params_code.substring(1)] = this.modalInfo.text
      } else {
        let params = {
          params_type: this.modalInfo.params_type,
          params_name: this.modalInfo.params_name,
          params_code: this.modalInfo.params_code,
          text: this.modalInfo.text
        }
        aaa.params = JSON.stringify(params)
      }
      setorderapply(aaa).then(res => {
        if (res.data.data) {
          this.modelShow.show = false
          this.modalInfo.show = false
          this.init({ 'state': this.tab_info[1][this.tab_index] })
          this.initTabCount()
        } else {
          this.$Notice.error({ title: '获取事项列表失败', desc: res.data.errmsg })
        }
      })
    },
    showModel (status, title, url) {
      this.modelShow = { show: status, title: title }
      if (url) {
        this.showErcode(url)
      }
    },
    // 获取收受分离的社区列表
    getColumnsList () {
      getUserByMZList().then(res => {
        if (res.data.errcode === 0) {
          this.company_list = res.data.data
        } else {
          this.$Notice.error({ title: '', desc: res.data.errmsg })
        }
      })
    },
    // 刷新pdf模态框使用，不知道为什么这样就好用，也不敢问
    refreshData () {
      this.modal2 = false
      this.$nextTick(() => {
        this.modal2 = true
      })
    },
    showErcode (codeUrl) {
      let _this = this
      console.log(codeUrl)
      setTimeout(function () {
        _this.getCode(codeUrl)
      }, 1000)
    },
    getCode (codeUrl) {
      document.getElementById('qrcode1').innerHTML = ''
      var qrcode = new QRCode(document.getElementById('qrcode1'), {
        text: codeUrl,
        top: 0,
        width: 150,
        height: 150,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      })
      console.log(qrcode, 'qrcode')
    }
  },
  mounted () {
    // console.log(this.$route.params, '111')
    this.tab_index = this.$route.params.tabindex || 0
    this.currentPageNo = this.$route.params.pageNo || 1
    this.init({ 'state': this.tab_info[1][this.tab_index] })
    this.initTabCount()
    this.getColumnsList()
  }
}
</script>
